import java.util.ArrayList;


public class NormalStrategy extends MonsterStrategy {
    
	private User user;
	
	public NormalStrategy(Map map, Monster monster, User user) {
		super(map, monster);
		this.user = user;
	}

	@Override
	protected void determineNextDirection(ArrayList<Integer> places) {
		int userX =user.getX()/Entity.getEntityWidth();
		int userY =user.getY()/Entity.getEntityHeight();
		int monsterX = monster.getX()/Entity.getEntityWidth();
		int monsterY = monster.getY()/Entity.getEntityHeight();
		int relPosX = userX - monsterX; 
		int relPosY = userY - monsterY;
		
		ArrayList<Integer> tmp = new ArrayList<Integer>();
		
		if(relPosX>0){
			if(places.contains(Monster.RIGHT)){
				tmp.add(Monster.RIGHT);
			}
		}else{
			if(places.contains(Monster.LEFT)){
				tmp.add(Monster.LEFT);
			}
		}
		
		if(relPosY>0){
			if(places.contains(Monster.DOWN)){
				tmp.add(Monster.DOWN);
			}
		}else{
			if(places.contains(Monster.UP)){
				tmp.add(Monster.UP);
			}
		}
		
		if (tmp.size() > 0) {
			moveRandom(tmp);
		} else {
			moveRandom(places);
		}
	}
}
